<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Produce</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Produce' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../intern.html">Inter Modules</a></li><li><a href="index.html">building</a></li><li><a href="index.html#3">Chapter 3: Masonry</a></li><li><b>Produce</b></li></ul></div>
<p class="purpose">Convenient machinery for generating individual Inter instructions.</p>

<ul class="toc"><li><a href="3-prd.html#SP3">&#167;3. Code insertion points</a></li><li><a href="3-prd.html#SP8">&#167;8. Levelling</a></li><li><a href="3-prd.html#SP12">&#167;12. The current function</a></li><li><a href="3-prd.html#SP17">&#167;17. Making material outside of functions</a></li><li><a href="3-prd.html#SP24">&#167;24. Making the code inside function bodies</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>This section provides a necessarily miscellaneous API for generating Inter
instructions: there are numerous different instructions, so there are many
different functions here, but there are few real ideas.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">site_production_data</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax"> </span><span class="identifier-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_CIP_STACK_SIZE</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">cip_sp</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> </span><span class="identifier-syntax">function_body_start_bookmark</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> </span><span class="identifier-syntax">function_locals_bookmark</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> </span><span class="identifier-syntax">function_body_code_bookmark</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">current_inter_function</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">site_production_data</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure site_production_data is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>The bookmarks here are meaningless unless a function is being compiled, and
then they will be given explicit values, so it really doesn't matter what they
are initialised to. But to avoid any doubt, they will be set to the root of <span class="extract"><span class="extract-syntax">I</span></span>,
even though they will never be used in that state.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::clear_site_data</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Produce::clear_site_data</span></span>:<br/>Building Module - <a href="1-bm.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">building_site</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_body_start_bookmark</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterBookmark::at_start_of_this_repository</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_locals_bookmark</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterBookmark::at_start_of_this_repository</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_body_code_bookmark</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterBookmark::at_start_of_this_repository</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Code insertion points.</b>From the caller's point of view, the functions in this section just magically
know where in the Inter tree we want to generate code. Such a position is
called a <a href="3-prd.html#SP3" class="internal">code_insertion_point</a> or CIP, and we must maintain it carefully.
We keep not just one but a stack of them, so that the caller can interrupt
one compilation activity, start another, and then resume the original.
</p>

<p class="commentary">For <a href="../inform7/index.html" class="internal">inform7</a>, this stack in fact never exceeds size 2, i.e., that first
interruption is never interrupted. If we ever need that, we can simply raise
<span class="extract"><span class="extract-syntax">MAX_CIP_STACK_SIZE</span></span>.
</p>

<p class="commentary">Each CIP contains a further stack of "noted levels" &mdash; where certain code
blocks, belonging to loop and conditional constructs, are placed. (Every Inter
instruction has a level, meaning, its hierarchical depth within the code
package: a level 3 instruction is three code blocks deep.) One of the easiest
ways to get errors when generating Inter code is to lose track of these levels
and generate instructions which are one level off; so, managing levels here
makes the caller's life much easier.
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MAX_CIP_STACK_SIZE</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">MAX_NESTED_NOTEWORTHY_LEVELS</span><span class="plain-syntax"> </span><span class="constant-syntax">256</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_level</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">noted_levels</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_NESTED_NOTEWORTHY_LEVELS</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">noted_sp</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">level_error_occurred</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">insertion_bm</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved_bm</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure code_insertion_point is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>When a new CIP is generated with a new write position, it saves a bookmark
holding the previous write position:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::push_new_code_position_saving</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Produce::push_new_code_position_saving</span></span>:<br/><a href="3-prd.html#SP5">&#167;5</a>, <a href="3-prd.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">new_IBM</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> </span><span class="identifier-syntax">old_IBM</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax"> </span><span class="identifier-syntax">cip</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">.</span><span class="element-syntax">inter_level</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) (</span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">new_IBM</span><span class="plain-syntax">) + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">.</span><span class="element-syntax">noted_sp</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">.</span><span class="element-syntax">level_error_occurred</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">.</span><span class="element-syntax">insertion_bm</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_IBM</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">.</span><span class="element-syntax">saved_bm</span><span class="plain-syntax"> = </span><span class="identifier-syntax">old_IBM</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_CIP_STACK_SIZE</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP overflow"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">cip</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>That saved position is usually the current write position, so this function is
convenient:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::push_new_code_position</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP4" class="function-link"><span class="function-syntax">Produce::push_new_code_position_saving</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterBookmark::snapshot</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">)));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>And this reverts to the previous position:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::pop_code_position</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Produce::pop_code_position</span></span>:<br/><a href="3-prd.html#SP15">&#167;15</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP underflow"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1].</span><span class="element-syntax">level_error_occurred</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"levelling error in CIP"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::set_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1].</span><span class="element-syntax">saved_bm</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>A bookmark for the current write position can now always be obtained thus:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::at</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Produce::at</span></span>:<br/><a href="3-prd.html#SP24">&#167;24</a>, <a href="3-prd.html#SP26">&#167;26</a>, <a href="3-prd.html#SP27">&#167;27</a>, <a href="3-prd.html#SP28">&#167;28</a>, <a href="3-prd.html#SP29">&#167;29</a>, <a href="3-prd.html#SP32">&#167;32</a>, <a href="3-prd.html#SP34">&#167;34</a>, <a href="3-prd.html#SP35">&#167;35</a>, <a href="3-prd.html#SP37">&#167;37</a>, <a href="3-prd.html#SP38">&#167;38</a>, <a href="3-prd.html#SP40">&#167;40</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP level accessed outside function"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1].</span><span class="element-syntax">insertion_bm</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Levelling.</b>As noted above, Inter instructions occur at "levels" which need to be kept track
of. This returns the level at the current write position:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::level</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Produce::level</span></span>:<br/><a href="3-prd.html#SP9">&#167;9</a>, <a href="3-prd.html#SP11">&#167;11</a>, <a href="3-prd.html#SP24">&#167;24</a>, <a href="3-prd.html#SP26">&#167;26</a>, <a href="3-prd.html#SP27">&#167;27</a>, <a href="3-prd.html#SP28">&#167;28</a>, <a href="3-prd.html#SP29">&#167;29</a>, <a href="3-prd.html#SP32">&#167;32</a>, <a href="3-prd.html#SP34">&#167;34</a>, <a href="3-prd.html#SP35">&#167;35</a>, <a href="3-prd.html#SP37">&#167;37</a>, <a href="3-prd.html#SP38">&#167;38</a>, <a href="3-prd.html#SP40">&#167;40</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP level accessed outside function"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1].</span><span class="element-syntax">inter_level</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b><a href="3-prd.html#SP9" class="internal">Produce::down</a> is so called because it takes us one level deeper in the tree;
this increases the level by 1. Similarly, <a href="3-prd.html#SP9" class="internal">Produce::up</a> heads back up towards
the root, decreasing the level by 1. The caller should be careful to ensure that
calls to these functions exactly match each other: for each down there must be
a matching up.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::down</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Produce::down</span></span>:<br/><a href="3-prd.html#SP25">&#167;25</a><br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_1">&#167;3.1.1</a>, <a href="2-eis.html#SP3_1_2">&#167;3.1.2</a>, <a href="2-eis.html#SP3_1_3">&#167;3.1.3</a>, <a href="2-eis.html#SP3_1_4">&#167;3.1.4</a>, <a href="2-eis.html#SP3_1_6">&#167;3.1.6</a>, <a href="2-eis.html#SP3_1_7">&#167;3.1.7</a>, <a href="2-eis.html#SP3_1_9">&#167;3.1.9</a>, <a href="2-eis.html#SP3_1_10">&#167;3.1.10</a>, <a href="2-eis.html#SP3_1_11">&#167;3.1.11</a>, <a href="2-eis.html#SP3_1_11_1">&#167;3.1.11.1</a>, <a href="2-eis.html#SP3_1_12">&#167;3.1.12</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP11" class="function-link"><span class="function-syntax">Produce::set_level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::up</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Produce::up</span></span>:<br/><a href="3-prd.html#SP25">&#167;25</a><br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_1">&#167;3.1.1</a>, <a href="2-eis.html#SP3_1_2">&#167;3.1.2</a>, <a href="2-eis.html#SP3_1_3">&#167;3.1.3</a>, <a href="2-eis.html#SP3_1_4">&#167;3.1.4</a>, <a href="2-eis.html#SP3_1_6">&#167;3.1.6</a>, <a href="2-eis.html#SP3_1_7">&#167;3.1.7</a>, <a href="2-eis.html#SP3_1_9">&#167;3.1.9</a>, <a href="2-eis.html#SP3_1_10">&#167;3.1.10</a>, <a href="2-eis.html#SP3_1_11">&#167;3.1.11</a>, <a href="2-eis.html#SP3_1_11_1">&#167;3.1.11.1</a>, <a href="2-eis.html#SP3_1_12">&#167;3.1.12</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP11" class="function-link"><span class="function-syntax">Produce::set_level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">) - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>In addition, the user can call the following to jump the level to some
position with respect to the currently code block being written. This should
only be used as a last resort when the level has unavoidably been lost track of,
e.g., when a schema has to compile a fragment of a code block missing its beginning
or end.
</p>

<p class="commentary">The levelling stack is automatically maintained. As new code blocks open (or,
more properly, as Inter primitives which take code blocks are generated), the
level is automatically pushed. When the current write level washes below these
levels, the code blocks in question must be finished, and the levels are popped
automatically from the stack.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::set_level_to_current_code_block_plus</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Produce::set_level_to_current_code_block_plus</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP1_1">&#167;1.1</a>, <a href="2-eis.html#SP3_1_4">&#167;3.1.4</a>, <a href="2-eis.html#SP3_1_11">&#167;3.1.11</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">delta</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP level accessed outside routine"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cip</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">level_error_occurred</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP11" class="function-link"><span class="function-syntax">Produce::set_level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_levels</span><span class="plain-syntax">[</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax">-1] + </span><span class="identifier-syntax">delta</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>Those public functions are powered by these private ones.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::note_level_of_newly_opening_code_block</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Produce::note_level_of_newly_opening_code_block</span></span>:<br/><a href="3-prd.html#SP24">&#167;24</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP level accessed outside routine"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cip</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_NESTED_NOTEWORTHY_LEVELS</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_levels</span><span class="plain-syntax">[</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax">++] = </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::set_level</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">Produce::set_level</span></span>:<br/><a href="3-prd.html#SP9">&#167;9</a>, <a href="3-prd.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"CIP level accessed outside function"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">code_insertion_point</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cip</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">cip_sp</span><span class="plain-syntax">-1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">level_error_occurred</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_levels</span><span class="plain-syntax">[</span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax">-1] &lt; </span><span class="identifier-syntax">N</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">noted_sp</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cip</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">inter_level</span><span class="plain-syntax"> = </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. The current function.</b>It is also convenient to have this section manage the business of constructing
standard function packages.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::function_body</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">packaging_state</span><span class="plain-syntax"> *</span><span class="identifier-syntax">save</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">) == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no inter repository"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">save</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        *</span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="1-pck.html#SP12" class="function-link"><span class="function-syntax">Packaging::enter_home_of</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">package_request</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax"> = </span><a href="1-in.html#SP8" class="function-link"><span class="function-syntax">InterNames::location</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">R</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> == </span><a href="1-ls.html#SP4" class="function-link"><span class="function-syntax">LargeScale::main_request</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Routine outside of package: %n\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"routine outside of package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">block_iname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">iname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> </span><span class="identifier-syntax">save_ib</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterBookmark::snapshot</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP16" class="function-link"><span class="function-syntax">Produce::set_function</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP22" class="function-link"><span class="function-syntax">Produce::make_and_set_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">block_iname</span><span class="plain-syntax">, </span><a href="1-ls.html#SP19" class="function-link"><span class="function-syntax">LargeScale::package_type</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"_code"</span><span class="plain-syntax">)));</span>

<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">CodeInstruction::new</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">)) + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_body_start_bookmark</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterBookmark::shifted</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">IMMEDIATELY_AFTER_NODEPLACEMENT</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_locals_bookmark</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterBookmark::shifted</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">BEFORE_NODEPLACEMENT</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_body_code_bookmark</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterBookmark::snapshot</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">));</span>

<span class="plain-syntax">    </span><a href="3-prd.html#SP4" class="function-link"><span class="function-syntax">Produce::push_new_code_position_saving</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_body_code_bookmark</span><span class="plain-syntax">), </span><span class="identifier-syntax">save_ib</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>The caller can test whether a function is being made, and find its start
position if so:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::function_body_is_open</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::function_body_start_bookmark</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_body_start_bookmark</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>The following creates a local symbol, suitable for a local variable or a
label. Note that we return an <span class="extract"><span class="extract-syntax">inter_symbol</span></span>, not an iname: inames can never
refer to local resources like these.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::new_local_symbol</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">Produce::new_local_symbol</span></span>:<br/><a href="3-prd.html#SP36">&#167;36</a>, <a href="3-prd.html#SP39">&#167;39</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">InterSymbolsTable::create_with_unique_name</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterPackage::scope</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax">), </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>When the caller has finished compiling the function body, she should call:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::end_function_body</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP16" class="function-link"><span class="function-syntax">Produce::set_function</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP6" class="function-link"><span class="function-syntax">Produce::pop_code_position</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>If the caller doesn't want to use the mechanism above, and wants to make her
own damn packages, she can call the following: but should be careful to call
twice, first to set to the new function's package, then to reset it to <span class="extract"><span class="extract-syntax">NULL</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::set_function</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">Produce::set_function</span></span>:<br/><a href="3-prd.html#SP12">&#167;12</a>, <a href="3-prd.html#SP15">&#167;15</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Making material outside of functions.</b>That's enough of keeping track of things: from here on, the code in this section
will actually make some Inter. The lower-down APIs in <a href="../bytecode-module/index.html" class="internal">bytecode</a> only return
an <span class="extract"><span class="extract-syntax">inter_error_message</span></span> if something improper has been done; <a href="../inter/index.html" class="internal">inter</a> and
<a href="../inform7/index.html" class="internal">inform7</a>, when generating code on their own initiative, must never trigger
Inter errors. So we will guard against them, reacting with an immediate
internal error to halt the compiler if they occur.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::guard</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">Produce::guard</span></span>:<br/><a href="3-prd.html#SP12">&#167;12</a>, <a href="3-prd.html#SP19">&#167;19</a>, <a href="3-prd.html#SP20">&#167;20</a>, <a href="3-prd.html#SP21">&#167;21</a>, <a href="3-prd.html#SP22">&#167;22</a>, <a href="3-prd.html#SP23">&#167;23</a>, <a href="3-prd.html#SP24">&#167;24</a>, <a href="3-prd.html#SP26">&#167;26</a>, <a href="3-prd.html#SP27">&#167;27</a>, <a href="3-prd.html#SP28">&#167;28</a>, <a href="3-prd.html#SP29">&#167;29</a>, <a href="3-prd.html#SP32">&#167;32</a>, <a href="3-prd.html#SP34">&#167;34</a>, <a href="3-prd.html#SP35">&#167;35</a>, <a href="3-prd.html#SP37">&#167;37</a>, <a href="3-prd.html#SP38">&#167;38</a>, <a href="3-prd.html#SP39">&#167;39</a>, <a href="3-prd.html#SP40">&#167;40</a><br/>Large-Scale Structure - <a href="1-ls.html#SP10">&#167;10</a>, <a href="1-ls.html#SP17">&#167;17</a>, <a href="1-ls.html#SP18">&#167;18</a>, <a href="1-ls.html#SP19">&#167;19</a><br/>Inter Primitives - <a href="1-ip.html#SP14">&#167;14</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_error_message</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ERR</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ERR</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterErrors::issue</span><span class="plain-syntax">(</span><span class="identifier-syntax">ERR</span><span class="plain-syntax">); </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"inter error"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>"Level" is an issue outside of functions, too. In general, material will be
generated either inside a package or at the root level. The following returns
the level for material being generated in this location &mdash; 0 for the root level,
or the baseline of the current package plus 1, if we're in a package.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::baseline</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">Produce::baseline</span></span>:<br/><a href="3-prd.html#SP4">&#167;4</a>, <a href="3-prd.html#SP12">&#167;12</a>, <a href="3-prd.html#SP19">&#167;19</a>, <a href="3-prd.html#SP20">&#167;20</a>, <a href="3-prd.html#SP21">&#167;21</a>, <a href="3-prd.html#SP22">&#167;22</a>, <a href="3-prd.html#SP39">&#167;39</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IBM</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterBookmark::package</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InterPackage::is_a_root_package</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InterPackage::is_a_function_body</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><span class="identifier-syntax">InterPackage::baseline</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterPackage::parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">)) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><span class="identifier-syntax">InterPackage::baseline</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>Demonstrating both of these, some simple Inter instructions:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::nop</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">Produce::nop</span></span>:<br/>Packaging - <a href="1-pck.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP19" class="function-link"><span class="function-syntax">Produce::nop_at</span></a><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::nop_at</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">Produce::nop_at</span></span>:<br/>Packaging - <a href="1-pck.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">delta</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NopInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">) + </span><span class="identifier-syntax">delta</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::comment</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">Produce::comment</span></span>:<br/>Large-Scale Structure - <a href="1-ls.html#SP20">&#167;20</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax"> = </span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">CommentInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">)));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b>Defining a constant with numerical value <span class="extract"><span class="extract-syntax">val</span></span>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::numeric_constant</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="1-pck.html#SP12" class="function-link"><span class="function-syntax">Packaging::enter_home_of</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">con_s</span><span class="plain-syntax"> = </span><a href="1-in.html#SP9" class="function-link"><span class="function-syntax">InterNames::to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax"> = </span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ConstantInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">con_s</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_type</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">InterValuePairs::number</span><span class="plain-syntax">(</span><span class="identifier-syntax">val</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><a href="1-pck.html#SP12" class="function-link"><span class="function-syntax">Packaging::exit</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. </b>Defining a constant equal to the value of an already-existing symbol <span class="extract"><span class="extract-syntax">val_s</span></span>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::symbol_constant</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val_s</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="1-pck.html#SP12" class="function-link"><span class="function-syntax">Packaging::enter_home_of</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax"> = </span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">con_s</span><span class="plain-syntax"> = </span><a href="1-in.html#SP9" class="function-link"><span class="function-syntax">InterNames::to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_pair</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterValuePairs::symbolic</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">val_s</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ConstantInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">con_s</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_type</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><a href="1-pck.html#SP12" class="function-link"><span class="function-syntax">Packaging::exit</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">con_iname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. </b>Note that this function does two things: creates a new package at the current
write position, and then shifts the write position into that new package:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::make_and_set_package</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">Produce::make_and_set_package</span></span>:<br/><a href="3-prd.html#SP12">&#167;12</a><br/>Packaging - <a href="1-pck.html#SP13">&#167;13</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ptype</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">textual_name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">textual_name</span><span class="plain-syntax">, </span><span class="string-syntax">"%n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">PackageInstruction::new</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">textual_name</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterTypes::unchecked</span><span class="plain-syntax">(), </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ptype</span><span class="plain-syntax">, </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">)), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">P</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">textual_name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">) </span><span class="identifier-syntax">InterBookmark::move_into_package</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. </b>We make a new package and return it; but note the <span class="extract"><span class="extract-syntax">+1</span></span> here &mdash; the package
is created at the level below that in <span class="extract"><span class="extract-syntax">IBM</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::make_subpackage</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ptype</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">PackageInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterTypes::unchecked</span><span class="plain-syntax">(), </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ptype</span><span class="plain-syntax">, (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><span class="identifier-syntax">InterBookmark::baseline</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">P</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. Making the code inside function bodies.</b>We begin with invocations: usages of the <span class="extract"><span class="extract-syntax">inv</span></span> instruction. This of course has
three uses. First, primitives:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::inv_primitive</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">Produce::inv_primitive</span></span>:<br/><a href="3-prd.html#SP25">&#167;25</a>, <a href="3-prd.html#SP28">&#167;28</a><br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_2_2">&#167;3.1.2.2</a>, <a href="2-eis.html#SP3_1_3">&#167;3.1.3</a>, <a href="2-eis.html#SP3_1_6">&#167;3.1.6</a>, <a href="2-eis.html#SP3_1_7">&#167;3.1.7</a>, <a href="2-eis.html#SP3_1_9">&#167;3.1.9</a>, <a href="2-eis.html#SP3_1_10">&#167;3.1.10</a>, <a href="2-eis.html#SP3_1_11">&#167;3.1.11</a>, <a href="2-eis.html#SP3_1_12">&#167;3.1.12</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">bip</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prim_symb</span><span class="plain-syntax"> = </span><a href="1-ip.html#SP16" class="function-link"><span class="function-syntax">Primitives::from_BIP</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">bip</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="1-ip.html#SP11" class="function-link"><span class="function-syntax">Primitives::takes_code_blocks</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">bip</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">bip</span><span class="plain-syntax"> != </span><span class="constant-syntax">CASE_BIP</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">bip</span><span class="plain-syntax"> != </span><span class="constant-syntax">DEFAULT_BIP</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP11" class="function-link"><span class="function-syntax">Produce::note_level_of_newly_opening_code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">InvInstruction::new_primitive</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">prim_symb</span><span class="plain-syntax">, (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP25" class="paragraph-anchor"></a><b>&#167;25. </b>These occur often enough to be worth defining here:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::rtrue</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">Produce::rtrue</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7">&#167;3.1.7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP24" class="function-link"><span class="function-syntax">Produce::inv_primitive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="constant-syntax">RETURN_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::down</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::number</span><span class="plain-syntax">(1)); </span><span class="comment-syntax"> that is, return "true"</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::up</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::rfalse</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP24" class="function-link"><span class="function-syntax">Produce::inv_primitive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="constant-syntax">RETURN_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::down</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::number</span><span class="plain-syntax">(0)); </span><span class="comment-syntax"> that is, return "false"</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::up</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::push</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP24" class="function-link"><span class="function-syntax">Produce::inv_primitive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="constant-syntax">PUSH_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::down</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP30" class="function-link"><span class="function-syntax">Produce::val_iname</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::up</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::pull</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP24" class="function-link"><span class="function-syntax">Produce::inv_primitive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="constant-syntax">PULL_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::down</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP34" class="function-link"><span class="function-syntax">Produce::ref_iname</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP9" class="function-link"><span class="function-syntax">Produce::up</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP26" class="paragraph-anchor"></a><b>&#167;26. </b>Assembly language:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::inv_assembly</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">Produce::inv_assembly</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_1">&#167;3.1.1</a>, <a href="2-eis.html#SP3_1_11">&#167;3.1.11</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">opcode</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">InvInstruction::new_assembly</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">opcode</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP27" class="paragraph-anchor"></a><b>&#167;27. </b>The "assembly marker" punctuation can be placed thus:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::assembly_marker</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">Produce::assembly_marker</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">AssemblyInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">which</span><span class="plain-syntax">, (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP28" class="paragraph-anchor"></a><b>&#167;28. </b>Function calls:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::inv_call_symbol</span><button class="popup" onclick="togglePopup('usagePopup23')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup23">Usage of <span class="code-font"><span class="function-syntax">Produce::inv_call_symbol</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_2_2">&#167;3.1.2.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">fn_s</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">InvInstruction::new_function_call</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">fn_s</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::inv_call_iname</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">fn_iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP28" class="function-link"><span class="function-syntax">Produce::inv_call_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><a href="1-in.html#SP9" class="function-link"><span class="function-syntax">InterNames::to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">fn_iname</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::inv_indirect_call</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">arity</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP24" class="function-link"><span class="function-syntax">Produce::inv_primitive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><a href="1-ip.html#SP7" class="function-link"><span class="function-syntax">Primitives::BIP_for_indirect_call_returning_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">arity</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP29" class="paragraph-anchor"></a><b>&#167;29. </b>Instructions for changing the primitive category:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::code</span><button class="popup" onclick="togglePopup('usagePopup24')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup24">Usage of <span class="code-font"><span class="function-syntax">Produce::code</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_4">&#167;3.1.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">CodeInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::evaluation</span><button class="popup" onclick="togglePopup('usagePopup25')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup25">Usage of <span class="code-font"><span class="function-syntax">Produce::evaluation</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7">&#167;3.1.7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">EvaluationInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::reference</span><button class="popup" onclick="togglePopup('usagePopup26')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup26">Usage of <span class="code-font"><span class="function-syntax">Produce::reference</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7">&#167;3.1.7</a>, <a href="2-eis.html#SP3_1_10">&#167;3.1.10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ReferenceInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP30" class="paragraph-anchor"></a><b>&#167;30. </b>The <span class="extract"><span class="extract-syntax">val</span></span> instruction. First, we can take the value of something identified
by an iname:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_iname</span><button class="popup" onclick="togglePopup('usagePopup27')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup27">Usage of <span class="code-font"><span class="function-syntax">Produce::val_iname</span></span>:<br/><a href="3-prd.html#SP25">&#167;25</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">iname</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no iname"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::number</span><span class="plain-syntax">(0)); </span><span class="comment-syntax"> for error recovery</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP31" class="function-link"><span class="function-syntax">Produce::val_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><a href="1-in.html#SP9" class="function-link"><span class="function-syntax">InterNames::to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">iname</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP31" class="paragraph-anchor"></a><b>&#167;31. </b>But that essentially reduces to this, taking the value of a symbol:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_symbol</span><button class="popup" onclick="togglePopup('usagePopup28')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup28">Usage of <span class="code-font"><span class="function-syntax">Produce::val_symbol</span></span>:<br/><a href="3-prd.html#SP30">&#167;30</a><br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a>, <a href="2-eis.html#SP3_1_10_2">&#167;3.1.10.2</a>, <a href="2-eis.html#SP3_1_11_1">&#167;3.1.11.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">s</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_pair</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterValuePairs::symbolic</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">s</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">val</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP32" class="paragraph-anchor"></a><b>&#167;32. </b>Which in turn falls into this, the general case: a value specified by an
Inter pair &mdash;
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val</span><button class="popup" onclick="togglePopup('usagePopup29')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup29">Usage of <span class="code-font"><span class="function-syntax">Produce::val</span></span>:<br/><a href="3-prd.html#SP25">&#167;25</a>, <a href="3-prd.html#SP30">&#167;30</a>, <a href="3-prd.html#SP31">&#167;31</a>, <a href="3-prd.html#SP33">&#167;33</a><br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_6">&#167;3.1.6</a>, <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a><br/>Value Holsters - <a href="3-vh.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_pair</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> != </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">val_kind</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val_kind</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no kind for val"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ValInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">InterTypes::from_type_name</span><span class="plain-syntax">(</span><span class="identifier-syntax">val_kind</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP33" class="paragraph-anchor"></a><b>&#167;33. </b>There remain some convenience functions for making such pairs.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_nothing</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::number</span><span class="plain-syntax">(0));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_text</span><button class="popup" onclick="togglePopup('usagePopup30')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup30">Usage of <span class="code-font"><span class="function-syntax">Produce::val_text</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::from_text</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_char</span><button class="popup" onclick="togglePopup('usagePopup31')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup31">Usage of <span class="code-font"><span class="function-syntax">Produce::val_char</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::number</span><span class="plain-syntax">((</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><span class="identifier-syntax">c</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_real</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">double</span><span class="plain-syntax"> </span><span class="identifier-syntax">g</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::real</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">g</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_real_from_text</span><button class="popup" onclick="togglePopup('usagePopup32')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup32">Usage of <span class="code-font"><span class="function-syntax">Produce::val_real_from_text</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::real_from_I6_notation</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::val_dword</span><button class="popup" onclick="togglePopup('usagePopup33')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup33">Usage of <span class="code-font"><span class="function-syntax">Produce::val_dword</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP32" class="function-link"><span class="function-syntax">Produce::val</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">InterValuePairs::from_singular_dword</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP34" class="paragraph-anchor"></a><b>&#167;34. </b>The <span class="extract"><span class="extract-syntax">ref</span></span> instruction is simpler. It makes no sense to have a storage reference
to a constant, so we only ever need to refer to inames or their symbols:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::ref_iname</span><button class="popup" onclick="togglePopup('usagePopup34')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup34">Usage of <span class="code-font"><span class="function-syntax">Produce::ref_iname</span></span>:<br/><a href="3-prd.html#SP25">&#167;25</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP34" class="function-link"><span class="function-syntax">Produce::ref_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><a href="1-in.html#SP9" class="function-link"><span class="function-syntax">InterNames::to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">iname</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::ref_symbol</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">s</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_pair</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterValuePairs::symbolic</span><span class="plain-syntax">(</span><a href="1-pck.html#SP7" class="function-link"><span class="function-syntax">Packaging::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">s</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> != </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">val_kind</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val_kind</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no kind for ref"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">RefInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">InterTypes::from_type_name</span><span class="plain-syntax">(</span><span class="identifier-syntax">val_kind</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP35" class="paragraph-anchor"></a><b>&#167;35. </b><span class="extract"><span class="extract-syntax">cast</span></span> may yet disappear from Inter: it doesn't really accomplish anything at
present, and is more of a placeholder than anything else.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::cast</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_type</span><span class="plain-syntax"> </span><span class="identifier-syntax">F_t</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_type</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_type</span><span class="plain-syntax"> </span><span class="identifier-syntax">T_t</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_type</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">CastInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">F_t</span><span class="plain-syntax">, </span><span class="identifier-syntax">T_t</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::kind_to_symbol</span><button class="popup" onclick="togglePopup('usagePopup35')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup35">Usage of <span class="code-font"><span class="function-syntax">Produce::kind_to_symbol</span></span>:<br/><a href="3-prd.html#SP32">&#167;32</a>, <a href="3-prd.html#SP34">&#167;34</a>, <a href="3-prd.html#SP39">&#167;39</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">CORE_MODULE</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">K</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">construct</span><span class="plain-syntax"> == </span><span class="identifier-syntax">CON_INTERMEDIATE</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="1-in.html#SP9" class="function-link"><span class="function-syntax">InterNames::to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">RTKindDeclarations::iname</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">CORE_MODULE</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">inter_type</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::kind_to_type</span><button class="popup" onclick="togglePopup('usagePopup36')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup36">Usage of <span class="code-font"><span class="function-syntax">Produce::kind_to_type</span></span>:<br/><a href="3-prd.html#SP20">&#167;20</a>, <a href="3-prd.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_type</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterTypes::unchecked</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) </span><span class="identifier-syntax">type</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterTypes::from_type_name</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::kind_to_TID</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_type</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_type</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">InterTypes::to_TID_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">type</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP36" class="paragraph-anchor"></a><b>&#167;36. </b>The following reserves a label, that is, declares that a given name will be
that of a label in the function currently being constructed.
</p>

<p class="commentary">Label names must begin with a <span class="extract"><span class="extract-syntax">.</span></span>, and we enforce that here.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::reserve_label</span><button class="popup" onclick="togglePopup('usagePopup37')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup37">Usage of <span class="code-font"><span class="function-syntax">Produce::reserve_label</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a>, <a href="2-eis.html#SP3_1_8">&#167;3.1.8</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get_first_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">lname</span><span class="plain-syntax">) != </span><span class="character-syntax">'.'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">dotted</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">dotted</span><span class="plain-syntax">, </span><span class="string-syntax">".%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">lname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lab_name</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP36" class="function-link"><span class="function-syntax">Produce::reserve_label</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">dotted</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">dotted</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lab_name</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP39" class="function-link"><span class="function-syntax">Produce::local_exists</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">lname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">lab_name</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP14" class="function-link"><span class="function-syntax">Produce::new_local_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">lname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">InterSymbol::make_label</span><span class="plain-syntax">(</span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP37" class="paragraph-anchor"></a><b>&#167;37. </b>This places the label at the current write position:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::place_label</span><button class="popup" onclick="togglePopup('usagePopup38')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup38">Usage of <span class="code-font"><span class="function-syntax">Produce::place_label</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_8">&#167;3.1.8</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">LabelInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">lab_name</span><span class="plain-syntax">, (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP38" class="paragraph-anchor"></a><b>&#167;38. </b>And here we make a <span class="extract"><span class="extract-syntax">lab</span></span> instruction, suitable for a jump instruction to use.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::lab</span><button class="popup" onclick="togglePopup('usagePopup39')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup39">Usage of <span class="code-font"><span class="function-syntax">Produce::lab</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_7_2">&#167;3.1.7.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">LabInstruction::new</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">L</span><span class="plain-syntax">, (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP39" class="paragraph-anchor"></a><b>&#167;39. </b>Now for local variables.
</p>

<p class="commentary">Note that this function is not intended as the way high-level code in <a href="../inform7/index.html" class="internal">inform7</a>
should create a local variable: see <a href="../imperative-module/3-lv.html" class="internal">Local Variables (in imperative)</a> for that.
This function is at a lower level &mdash; it does the necessary Inter business, but
doesn't add the name tp the current stack frame in <a href="../inform7/index.html" class="internal">inform7</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::local</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lname</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">comm</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"local variable emitted outside function"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">local_s</span><span class="plain-syntax"> = </span><a href="3-prd.html#SP14" class="function-link"><span class="function-syntax">Produce::new_local_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">lname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">InterSymbol::make_local</span><span class="plain-syntax">(</span><span class="identifier-syntax">local_s</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">locals_at</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">function_locals_bookmark</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">comm</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">comm</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">CommentInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">locals_at</span><span class="plain-syntax">, </span><span class="identifier-syntax">comm</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">locals_at</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_type</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterTypes::unchecked</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> != </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">)) </span><span class="identifier-syntax">type</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterTypes::from_type_name</span><span class="plain-syntax">(</span><a href="3-prd.html#SP35" class="function-link"><span class="function-syntax">Produce::kind_to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">LocalInstruction::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">locals_at</span><span class="plain-syntax">, </span><span class="identifier-syntax">local_s</span><span class="plain-syntax">, </span><span class="identifier-syntax">type</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="3-prd.html#SP18" class="function-link"><span class="function-syntax">Produce::baseline</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">locals_at</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">local_s</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">Produce::local_exists</span><button class="popup" onclick="togglePopup('usagePopup40')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup40">Usage of <span class="code-font"><span class="function-syntax">Produce::local_exists</span></span>:<br/><a href="3-prd.html#SP36">&#167;36</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">InterSymbolsTable::symbol_from_name</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InterPackage::scope</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">site</span><span class="plain-syntax">.</span><span class="element-syntax">sprdata</span><span class="plain-syntax">.</span><span class="element-syntax">current_inter_function</span><span class="plain-syntax">), </span><span class="identifier-syntax">lname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP40" class="paragraph-anchor"></a><b>&#167;40. </b>And finally, code provenance markers:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Produce::provenance</span><button class="popup" onclick="togglePopup('usagePopup41')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup41">Usage of <span class="code-font"><span class="function-syntax">Produce::provenance</span></span>:<br/>Emitting Inter Schemas - <a href="2-eis.html#SP3_1_5_1">&#167;3.1.5.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_provenance</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="3-prd.html#SP17" class="function-link"><span class="function-syntax">Produce::guard</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ProvenanceInstruction::new_from_provenance</span><span class="plain-syntax">(</span><a href="3-prd.html#SP7" class="function-link"><span class="function-syntax">Produce::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">from</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><a href="3-prd.html#SP8" class="function-link"><span class="function-syntax">Produce::level</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="2-i6se.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-bm.html">1</a></li><li class="progresschapter"><a href="2-is.html">2</a></li><li class="progresscurrentchapter">3</li><li class="progresscurrent">prd</li><li class="progresssection"><a href="3-vh.html">vh</a></li><li class="progressnext"><a href="3-vh.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

